package com.ruoyi.binding.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.binding.domain.MhOrderRawData;
import com.ruoyi.binding.service.IMhOrderRawDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单管理数据Controller
 * 
 * @author Ekko
 * @date 2025-08-06
 */
@RestController
@RequestMapping("/order/raw")
public class MhOrderRawDataController extends BaseController
{
    @Autowired
    private IMhOrderRawDataService mhOrderRawDataService;

    /**
     * 查询订单管理数据列表
     */
    @PreAuthorize("@ss.hasPermi('order:raw:list')")
    @GetMapping("/list")
    public TableDataInfo list(MhOrderRawData mhOrderRawData)
    {
        startPage();
        List<MhOrderRawData> list = mhOrderRawDataService.selectMhOrderRawDataList(mhOrderRawData);
        return getDataTable(list);
    }

    /**
     * 导出订单管理数据列表
     */
    @PreAuthorize("@ss.hasPermi('order:raw:export')")
    @Log(title = "订单管理数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MhOrderRawData mhOrderRawData)
    {
        List<MhOrderRawData> list = mhOrderRawDataService.selectMhOrderRawDataList(mhOrderRawData);
        ExcelUtil<MhOrderRawData> util = new ExcelUtil<MhOrderRawData>(MhOrderRawData.class);
        util.exportExcel(response, list, "订单管理数据数据");
    }

    /**
     * 获取订单管理数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:raw:query')")
    @GetMapping(value = "/{oid}")
    public AjaxResult getInfo(@PathVariable("oid") Long oid)
    {
        return success(mhOrderRawDataService.selectMhOrderRawDataByOid(oid));
    }

    /**
     * 新增订单管理数据
     */
    @PreAuthorize("@ss.hasPermi('order:raw:add')")
    @Log(title = "订单管理数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MhOrderRawData mhOrderRawData)
    {
        return toAjax(mhOrderRawDataService.insertMhOrderRawData(mhOrderRawData));
    }

    /**
     * 修改订单管理数据
     */
    @PreAuthorize("@ss.hasPermi('order:raw:edit')")
    @Log(title = "订单管理数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MhOrderRawData mhOrderRawData)
    {
        return toAjax(mhOrderRawDataService.updateMhOrderRawData(mhOrderRawData));
    }

    /**
     * 删除订单管理数据
     */
    @PreAuthorize("@ss.hasPermi('order:raw:remove')")
    @Log(title = "订单管理数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{oids}")
    public AjaxResult remove(@PathVariable Long[] oids)
    {
        return toAjax(mhOrderRawDataService.deleteMhOrderRawDataByOids(oids));
    }
}
